const express = require('express')
const notesRouter = require('./controllers/notes')
const usersRouter = require('./controllers/users')
const loginRouter = require('./controllers/login')
const middleware = require('./utils/middleware')
const cors = require('cors')
const app = new express()
app.use(cors())
app.use(express.json())
app.use(middleware.commonRes)
app.use(middleware.requestLogger)
app.use(middleware.tokenExtractor)
app.use('/api/login', loginRouter)
app.use('/api/notes', notesRouter)
app.use('/api/users', usersRouter)
app.use(middleware.errorHandler)
app.use('/static', express.static('build'))
module.exports = app
